package com.jyy.prefabricated.service;

import com.jyy.prefabricated.entity.ExamPaperAreaRule;
import com.jyy.prefabricated.exception.CustomException;
import com.jyy.prefabricated.mapper.ExamPaperAreaRuleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @version 1.0.0
 * @author: zjj
 */

@Service
public class ExamPaperAreaRuleService {

    @Autowired
    private ExamPaperAreaRuleMapper ruleMapper;

    /**
     * 新增
     * @param rule
     * @return
     */
    public int insert(ExamPaperAreaRule rule){
        ruleMapper.insert(rule);
        return rule.getId();
    }

    /**
     * 更新
     * @param rule
     * @return
     */
    public int update(ExamPaperAreaRule rule){
        if(rule.getId() == null){
            throw new CustomException("参数id不能为空");
        }
        return ruleMapper.updateByPrimaryKeySelective(rule);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    public int delete(Integer id){
        return ruleMapper.deleteByPrimaryKey(id);
    }

    /**
     * 根据id查询
     * @param id
     * @return
     */
    public ExamPaperAreaRule selectById(Integer id){
        return ruleMapper.selectByPrimaryKey(id);
    }
}
